package JDBC;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import JDBC.connexionBDD;

import Model.Cours;
import Model.Eleve;

public class Cours_Afficher 
{
	public ArrayList<Cours> afficher(int idEleve, int idProf)
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{
			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours WHERE id_eleve="+idEleve+" AND id_professeur="+idProf);
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());
				
				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}
		
		return mesCours;
	}
	
	public Cours afficherCours(int idCours)
	{
		Cours cours = new Cours();
		String adresse=null;
		int idLieu=0;
		try 
		{
			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();
			Statement state7 = conn.createStatement();
			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours WHERE id_cours="+idCours);
			
			while(result.next())
			{	
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());
				idLieu=Integer.parseInt(result.getObject(6).toString());
				cours.setId_Lieu(idLieu);
				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				ResultSet result7=state7.executeQuery("SELECT numero, rue, complement, codepostal, ville FROM lieu WHERE id_lieu="+idLieu);
				while(result7.next())
				{
					adresse=result7.getObject(1).toString()+" "+result7.getObject(2).toString()+" "+result7.getObject(3).toString()+" "+result7.getObject(4).toString()+" "+result7.getObject(5).toString()+" ";
					
				}
				result7.close();
				cours.setAdresse(adresse);
				
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				cours.setId_Prof(Integer.parseInt(result.getObject(7).toString()));
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				cours.setId_Mat(Integer.parseInt(result.getObject(8).toString()));
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				cours.setId_Niv(Integer.parseInt(result.getObject(9).toString()));
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				cours.setId_Eleve(Integer.parseInt(result.getObject(10).toString()));
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				cours.toString();
				
			}
			
			result.close();
			state.close();
		}
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		
		return cours;
	}
	
	public ArrayList<Cours> afficherCours() 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours ORDER BY id_cours");
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());
				cours.setId_Lieu(Integer.parseInt(result.getObject(6).toString()));
				
				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
	
	public ArrayList<Cours> afficherCours(String attribut, String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours ORDER BY "+attribut+" "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
	
	public ArrayList<Cours> afficherCoursParMatiere(String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours c, matiere m where m.id_matiere=c.id_matiere ORDER BY m.libelle_mat "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
	
	public ArrayList<Cours> afficherCoursParNiveau(String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours c, niveau m where m.id_niveau=c.id_niveau ORDER BY m.libelle_niveau "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
	
	public ArrayList<Cours> afficherCoursParEleve(String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours c, eleve m where m.id_eleve=c.id_eleve ORDER BY m.nom_eleve "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
	
	public ArrayList<Cours> afficherCoursParProf(String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours c, professeur m where m.id_professeur=c.id_professeur ORDER BY m.nom_prof "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}

	public ArrayList<Cours> afficherCoursParVille(String sens) 
	{
		ArrayList<Cours> mesCours = new ArrayList<Cours>();
		
		try 
		{

			connexionBDD a = new connexionBDD();
			Connection conn=a.connect();

			//Création d'un objet Statement
			Statement state = conn.createStatement();
			Statement state2 = conn.createStatement();
			Statement state3 = conn.createStatement();
			Statement state4 = conn.createStatement();
			Statement state5 = conn.createStatement();
			Statement state6 = conn.createStatement();

			//L'objet ResultSet contient le résultat de la requête SQL
			ResultSet result = state.executeQuery("SELECT * FROM cours c, lieu m where m.id_lieu=c.id_lieu ORDER BY ville "+sens);
			
			
			
			while(result.next())
			{	
				Cours cours = new Cours();
				cours.setIdCours(Integer.parseInt(result.getObject(1).toString()));
				cours.setDateCours(result.getObject(2).toString());
				cours.setDuree(Integer.parseInt(result.getObject(3).toString()));
				cours.setHeureDebut(result.getObject(4).toString());
				cours.setHeureFin(result.getObject(5).toString());

				ResultSet result6 = state6.executeQuery("SELECT ville FROM lieu where id_lieu="+Integer.parseInt(result.getObject(6).toString()));
				
				while(result6.next())
				{
					cours.setVille(result6.getObject(1).toString());
				}
				
				result6.close();
				
				ResultSet result4 = state4.executeQuery("SELECT nom_prof, prenom_prof FROM professeur where id_professeur="+Integer.parseInt(result.getObject(7).toString()));
				
				while(result4.next())
				{
					String[] prof = new String[2];
					prof[0]=result4.getObject(1).toString();
					prof[1]=result4.getObject(2).toString();
					cours.setProf(prof);
				}
				
				result4.close();
				
				ResultSet result2 = state2.executeQuery("SELECT libelle_mat FROM matiere where id_matiere="+Integer.parseInt(result.getObject(8).toString()));
				
				while(result2.next())
				{
					cours.setMatiere(result2.getObject(1).toString());
				}
				
				result2.close();
				
				ResultSet result3 = state3.executeQuery("SELECT libelle_niveau FROM niveau where id_niveau="+Integer.parseInt(result.getObject(9).toString()));
				
				while(result3.next())
				{
					cours.setNiveau(result3.getObject(1).toString());
				}
				
				result3.close();
				
				ResultSet result5 = state5.executeQuery("SELECT nom_eleve, prenom_eleve FROM eleve where id_eleve="+Integer.parseInt(result.getObject(10).toString()));
				
				while(result5.next())
				{
					String[] eleve = new String[2];
					eleve[0]=result5.getObject(1).toString();
					eleve[1]=result5.getObject(2).toString();
					cours.setEleve(eleve);
				}
				
				result5.close();
				
				mesCours.add(cours);
				cours.toString();
				
			}
			
			result.close();
			state.close();
		} 

		catch (Exception e) 
		{
			e.printStackTrace();
		}	
		return mesCours;

	}
}
